﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using GSLMS.Entity;
using GSLMS.Entity.Enum;
using GSLMS.Core;

namespace GSLMS.WebAPP.Areas.System.Controllers.Loger
{

    [Admin]
    public class LogerController : AdminBaseController
    {

        protected override string navTabId
        {
            get { return "System_OperationLog"; }
        }

        //
        // GET: /System/Loger/

        public ActionResult Index()
        {
            SearchPara(null);
            InitSelectList();
            return View(GetLogs(null));
        }

        [HttpPost]
        public ActionResult Index(FormCollection form)
        {
            SearchPara(form);
            InitSelectList();
            return View(GetLogs(form));
        }

       
        public string View(FormCollection form)
        {
            string result = string.Empty;


            return result;
        }

        private List<TB_SYS_LOG> GetLogs(FormCollection form)
        {
            var emps = new List<TB_SYS_LOG>();
            var searchParma = new TB_SYS_LOG();
            if (ViewData["SearchParma"] == null)
            {
                if (form == null || form.Count == 0)
                {
                    
                }
                else
                {
                    TryUpdateModel(searchParma, form);
                }
            }
            else
                searchParma = ViewData["SearchParma"] as GSLMS.Entity.TB_SYS_LOG ?? new GSLMS.Entity.TB_SYS_LOG();

            emps = serviceSysLog.GetList(searchParma);
            emps = emps ?? new List<TB_SYS_LOG>();
            ViewData["RowCount"] = searchParma.RowCount;
            return emps;
        }
        private TB_SYS_LOG SearchPara(FormCollection form)
        {
            var searchParma = new TB_SYS_LOG();
            if (form != null && form.Count > 0)
            {
                TryUpdateModel(searchParma, form);
            }
            ViewData["SearchParma"] = searchParma ?? new TB_SYS_LOG();
            return searchParma;
        }

        private void InitSelectList()
        {
            //ViewData["SalesMan"] = GetListFromDict("SalesMan");
            //ViewData["RegStatus"] = EnumHelper.ToSelectList<ApplyEnum.RegStatus>();
            //ViewData["Source"] = EnumHelper.ToSelectList<ApplyEnum.RegSource>();
            //ViewData["Mediator"] = new SelectList(new List<TB_REST_CHANNEL>());
            //ViewData["BussType"] = EnumHelper.ToSelectList<ApplyEnum.RegBussType>();
            //ViewData["Product"] = GetListFromDict("Product");
            //ViewData["ImportantLevel"] = GetListFromDict("ImportantLevel");
        }
    }
}
